package com.techsoul.module.pms.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.techsoul.module.pms.pojo.entity.PmsCustomer;
import com.techsoul.module.pms.pojo.param.PmsCustomerSearchParam;
import com.techsoul.module.pms.pojo.vo.PmsCustomerVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 客户Mapper接口
 * 
 * @author liuen
 * @date 2020-12-28
 */
public interface PmsCustomerMapper extends BaseMapper<PmsCustomer> {

    /**
     * 详情
     * @param id
     * @return
     */
    PmsCustomerVo findById(String id);

    /**
     * 详情-根据员工ID查询
     * @param employeeId
     * @return
     */
    PmsCustomerVo findByEmployeeId(String employeeId);

    /**
     * 列表
     * @param params
     * @return
     */
    List<PmsCustomerVo> findAll(@Param("params") PmsCustomerSearchParam params);
    List<PmsCustomer> findAllNeedSettleThisMonth(@Param("month") String month);
    /**
     * 分页
     * @param page
     * @param params
     * @return
     */
    IPage<PmsCustomerVo> findAll(Page page, @Param("params") PmsCustomerSearchParam params);

    /**
     * 查询首字母集合
     * @return
     */
    @Select("SELECT letter FROM pms_customer GROUP BY letter")
    List<String> findLetters();

    /**
     * 列表
     * @param letter
     * @return
     */
    @Select("SELECT id, customer_name AS name, letter AS sort FROM pms_customer WHERE letter = #{letter}")
    List<PmsCustomerVo> findAllByLetter(String letter);

}
